﻿Public Class Producto

    Private _nombre As String
    Private _precio As Decimal
    Private bannedchars As String = "ºª\!'¡¿?=)(/&%$·|@#~€¬^`[+*]´¨{}-_.,;:"
    Private _descripcion As String
    Private _IDproducto As String
    Public Overrides Function ToString() As String
        Return "Nombre: " & nombre & ", " & "Precio: " & precio & ", " & "Descripcion: " & descripcion
    End Function
    Public Property nombre As String
        Get
            Return _nombre
        End Get
        Set(ByVal value As String)
            For i = 0 To bannedchars.Count - 1
                If value.Contains(bannedchars(i)) Then
                    value = Nothing
                End If
            Next
            _nombre = value
        End Set
    End Property
    Public Property precio As Decimal
        Get
            Return _precio
        End Get
        Set(ByVal value As Decimal)
            If value < 0 Or value > Decimal.MaxValue Or Not IsNumeric(value) Then
                value = Nothing
            End If
            _precio = value
        End Set
    End Property
    Public Property descripcion As String
        Get
            Return _descripcion
        End Get
        Set(ByVal value As String)
            For i = 0 To bannedchars.Count - 1
                If value.Contains(bannedchars(i)) Then
                    value = Nothing
                End If
            Next
            _descripcion = value
        End Set
    End Property
    Public Sub New(ByVal name As String, ByVal price As Decimal, ByVal description As String)
        nombre = name
        precio = price
        descripcion = description
    End Sub
    Public Sub New()

    End Sub
    Public Property IDproducto As String
        Get
            Return _IDproducto
        End Get
        Set(ByVal value As String)
            _IDproducto = value
        End Set
    End Property
End Class
